/**
 * Created by jaylee on 16/7/27.
 */
'use strict';

stareal
    .controller("SettingsFeedbackController", function ($scope, $api, $alert, $state, localStorageService) {
        $scope.telphone_no = localStorageService.get("telphone_no");
        $scope.save = function () {
            if (!$scope.remark) {
                $alert.show('请输入反馈内容!');
                return;
            }
            function getOSVersion() { // 获取操作系统版本
                var OSVision = '1.0';
                var u = navigator.userAgent;
                var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //Android
                var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
                if (isAndroid) {
                    OSVision = 'Android '+navigator.userAgent.split(';')[1].match(/\d+\.\d+/g)[0];
                }
                if (isIOS) {
                    OSVision ='Ios '+ navigator.userAgent.split(';')[1].match(/(\d+)_(\d+)_?(\d+)?/)[0];
                }
                return OSVision;
            }
            var vis=getOSVersion();
            $api.get("app/feedback/create", {
                remark: $scope.remark,
                vno:'2.1.3',
                mobile_vno:vis
            }, true)
                .then(function (ret) {
                    $alert.show("您的意见是我们前进的动力!", function () {
                        $state.go("my.index", {});
                    }, true);
                }, function (err) {
                    $alert.show(err);
                });
        }
    });